#include"Task.hpp"
#include"ThreadPool.hpp"
#include<time.h>
#include<unistd.h>
void* Product(void* arg)
{
  //pthread_detach(pthread_self());
  ThreadPool<Task>* tp = static_cast<ThreadPool<Task>*>(arg);
  while(1)
  {
    const char* str = "+-*/%";
    int x = rand() % 20;
    int y = rand() % 10;
    char op = str[rand() % 5];
    cout << "发布的任务是: " << x <<" " << op <<" " << y << " = ?" << endl;  
    Task task(x,y,op);
    sleep(1);
    tp->push(task);
  }
}
int main()
{
  srand((size_t)time(nullptr));
  ThreadPool<Task> tp;
  tp.InitThreadPool();
  pthread_t pro;
  pthread_create(&pro,nullptr,Product,(void*)&tp);
  pthread_join(pro,nullptr);
  return 0;
}
